﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Common;
using System.Runtime.CompilerServices;

namespace DrugStore.Models
{
    #region Serivce    
        public class DrugBussiness
        {
            public List<ProductCategory> GetAllCategory() 
            {
                DrugStoreEntities entities = new DrugStoreEntities();
                return entities.ProductCategories.ToList();               
            }

            public List<Disease> GetDiseaseCategoryByName(String name) 
            {
                DrugStoreEntities entities = new DrugStoreEntities();

                var disease = from ca in entities.Diseases
                              where ca.DiseaseCategory.DieaseName == name
                              select ca;
                return disease.ToList<Disease>();
            }
            public List<Disease> GetDiseaseCategoryById(String id) 
            {
                Guid diseaseId = new Guid();
                DrugStoreEntities entities = new DrugStoreEntities();
                if (Guid.TryParse(id, out diseaseId))
                {
                    var diseases = from ca in entities.Diseases
                                   where ca.DiseaseCategoryId == diseaseId
                                   select ca;
                    return diseases.ToList<Disease>();

                }
                return null;              

            }

            public List<RetreatMeant> GetAllRetreatMeant() 
            {
                DrugStoreEntities entitties = new DrugStoreEntities();
                return entitties.RetreatMeants.ToList();
            }

            public List<DiseaseCategory> GetAllDiseaseCategories()
            {
                DrugStoreEntities entities = new DrugStoreEntities();
                return entities.DiseaseCategories.ToList();
            }            
                                        
        }    
    #endregion
}